package ma.fizazi.missionsmanagement.model;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.DiscriminatorColumn;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

@Entity
@Table(name = "ACTIVITES")
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name = "TYPE")
public class Activite implements Serializable{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;


	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	@Column(name="ID_ACTIVITE", unique=true, nullable =false)
	private int id;

	
	@Column
	protected boolean active;
	@Column
	protected String description;
	@Column
	protected String intitule;
	@Column
	protected int nombreExercice;
	@Column
	protected EtatMission missionEtat;

	@ManyToOne
	protected Client client;

	@ManyToOne
	protected NatureMission natureMission;

	@ManyToMany
	@JoinTable(name="USERS_ACTIVITES", joinColumns = {
	@JoinColumn(name="ID_ACTIVITE", nullable=false, updatable=false)},
	inverseJoinColumns = {@JoinColumn(name="ID_USER", nullable=false, updatable=false) }
			)
	protected List<Utilisateur> utilisateurs;
	
	public Activite() {

	}

	public void finalize() throws Throwable {

	}

	public boolean isActive() {
		return active;
	}

	public void setActive(boolean active) {
		this.active = active;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public String getIntitule() {
		return intitule;
	}

	public void setIntitule(String intitule) {
		this.intitule = intitule;
	}

	public EtatMission getMissionEtat() {
		return missionEtat;
	}

	public void setMissionEtat(EtatMission missionEtat) {
		this.missionEtat = missionEtat;
	}

	public int getNombreExercice() {
		return nombreExercice;
	}

	public void setNombreExercice(int nombreExercice) {
		this.nombreExercice = nombreExercice;
	}

	public Client getClient() {
		return client;
	}

	public void setClient(Client client) {
		this.client = client;
	}

	public NatureMission getNatureMission() {
		return natureMission;
	}

	public void setNatureMission(NatureMission natureMission) {
		this.natureMission = natureMission;
	}

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public List<Utilisateur> getUtilisateurs() {
		if(utilisateurs == null) {
			utilisateurs = new ArrayList<Utilisateur>();
		}
		return utilisateurs;
	}

	public void setUtilisateurs(List<Utilisateur> utilisateurs) {
		this.utilisateurs = utilisateurs;
	}


	
}